//
//  UIView+ScreenShot.m
//  TakeScreenShot
//
//  Created by yao zhaofeng on 2018/8/2.
//  Copyright © 2018年 YaoZhaofeng. All rights reserved.
//

#import "UIView+ScreenShot.h"

@implementation UIView (ScreenShot)
- (UIImage *)xy_screenshot {
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, [UIScreen mainScreen].scale);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData *imageData = UIImageJPEGRepresentation(image, 0.5);
    image = [UIImage imageWithData:imageData];
    return image;
}

@end
